package com.easy.service.impl;

import com.easy.bean.Customer;
import com.easy.bean.Stylist;
import com.easy.mapper.StylistDao;
import com.easy.service.StylistService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StylistServiceimpl implements StylistService {

    @Autowired
    StylistDao stylistDao;

    @Override
    public Stylist add(Stylist stylist) {
        // 新增数据
        stylistDao.add(stylist);
        // 通过主键查询数据库中的数据
        Stylist result = stylistDao.one(stylist.getId());
        return result;
    }

    @Override
    public int del(Integer id) {
        return stylistDao.del(id);
    }

    @Override
    public Stylist edit(Stylist stylist) {
        // 更新数据
        stylistDao.edit(stylist);
        // 通过主键查询更新后的数据
        Stylist result = stylistDao.one(stylist.getId());
        return result;
    }

    @Override
    public List<Stylist> all(Stylist stylist) {
        return stylistDao.all(stylist);
    }

    @Override
    public Stylist one(Integer id) {
        return stylistDao.one(id);
    }


    @Override
    public void page(Page page, Stylist stylist) {

        int count=stylistDao.pageCount(stylist);
        Object data=stylistDao.page(page,stylist);
        page.setCount(count);
        page.setData(data);
    }

    @Override
    public Stylist getByPhone(String phone) {
        return stylistDao.getByPhone(phone);
    }
}
